package com.czy.ekp.config;


import com.alibaba.fastjson.JSONObject;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

@ControllerAdvice
public class LocalExceptionHandler {


    @ExceptionHandler(value =Exception.class)
    @ResponseBody
    public String defaultHandler(Exception e){
        e.printStackTrace();

        JSONObject result = new JSONObject();
        result.put("code", 500);
        result.put("message", e.getMessage());
        return result.toJSONString();
    }


}
